package cn.ultrarisk.scadmin.manager.biz.solr.context;

/**
 * SolrState
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/5/11
 * @since V1.0
 */
public enum SolrState {
    LEADER,
    ACTIVE,
    RECOVERING,
    DOWN,
    RECOVERY_FAILED,
    GONE;

    public static SolrState get(String state) {
        if (state != null) {
            try {
                return SolrState.valueOf(state.toUpperCase().replace(" ", "_"));
            } catch (Exception ignored) {
            }
        }
        return null;
    }

    public static boolean isAlive(SolrState state) {
        return state == LEADER || state == ACTIVE;
    }
}
